﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RN.Entidades;
using RN.Componentes;

namespace Sitio
{
    public partial class WebFormModificarAsignacionCentrodeCostoResponsable : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {

                if (this.Session["usuario"] == null)
                {
                    Response.Redirect("Login.aspx");
                }

                CargarGrid();
            }
        }
        public void CargarGrid()
        {
            List<CENTRODECOSTO_ASIGNACION_PERSONAL> obj = CCentrodeCostos_Asignacion_Personal.Traergrid();
            grdcENTRODECOSTO.DataSource = obj;
            grdcENTRODECOSTO.DataBind();
        }
        protected void grdFamilias_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
        protected void ResultGrid_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int id = Convert.ToInt32(e.CommandArgument);
            if (e.CommandName == "ASIGNAR")
            {
                if (CCentrodeCostos_Asignacion_Personal.Eliminar(id))
                {
                    Label1.Text=("SE HA DESASIGNADO CORRECTAMENTE");
                    CargarGrid();
                }
                else {
                    Label1.Text="ERROR AL DESASIGNAR";
                }
            }

    

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Redirect("./Principal.aspx");
        }
    }
}